#include <iostream>
#include <algorithm> 
#include <string>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void replace_string(string& str,const string& old_str,const string& new_str)
{
    int p=0;
    while((p=str.find(old_str,p))!=string::npos){
		str.replace(p,old_str.size(),new_str);
		p+=new_str.size();
	}
}
int main(int argc, char** argv) {
	string s ="tru tro tru";
	replace_string(s,"tru","tro");
	return 0;
}
